package com.koron.car.web.applycar.bean.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author yijian
 */
@Data
@ApiModel("根据月份统计车辆信息报表")
public class CarStatisticalReportVO {

    @ApiModelProperty("车牌号")
    private String licPlateNum;

    @ApiModelProperty("车牌名称")
    private String motorcadeName;

    @ApiModelProperty("车牌id")
    private String motorcade;

    @ApiModelProperty("车型")
    private String model;

    @ApiModelProperty("购车价格")
    private Double purchasePrice;

    @ApiModelProperty("购车时间")
    private String purchaseDate;

    @ApiModelProperty("月初里程")
    private String monthBeginDistance;

    @ApiModelProperty("月末里程")
    private String monthEndDistance;

    @ApiModelProperty("里程数")
    private Double totalDistance;

    @ApiModelProperty("用油量")
    @JsonProperty(defaultValue = "0.0")
    private Double oil;

    @ApiModelProperty("加油费")
    private Double cost;

    @ApiModelProperty("百公里油耗")
    private Double oilCost;

    @ApiModelProperty("维修费")
    private Double matainFee;

    @ApiModelProperty("ETC")
    private Double tollFee;

    @ApiModelProperty("当前月份")
    private String month;

    public Double getTotalDistance() {
        Double begin = Double.valueOf(monthBeginDistance) == null ? 0.00 : Double.valueOf(monthBeginDistance);
        Double end = Double.valueOf(monthEndDistance) == null ? 0.00 : Double.valueOf(monthEndDistance);
        totalDistance = end - begin;
        return totalDistance;
    }

    public Double getOilCost(){
        Double begin = Double.valueOf(monthBeginDistance) == null ? 0.00 : Double.valueOf(monthBeginDistance);
        Double end = Double.valueOf(monthEndDistance) == null ? 0.00 : Double.valueOf(monthEndDistance);
        totalDistance = end - begin;
        if (totalDistance.equals(0.0)){
            return 0.0;
        }
        if (oil.equals(0.0)){
            return 0.0;
        }
        Double temp = oil / totalDistance * 100;
        BigDecimal bigDecimal = BigDecimal.valueOf(temp);
        temp = bigDecimal.setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue();
        return temp;
    }
}
